﻿package plugin.juezhan.ui
{
    import flash.display.*;
    import flash.events.*;
    import plugin.component.view.*;
    import uiresource.juezhan.*;

    public class ZhanshiCtrl extends ZhanshiUI
    {
        private var sp:Sprite;
        private var roleshow:RoleShow;
        private var _model:String = "";

        public function ZhanshiCtrl()
        {
            this.mouseEnabled = false;
            this.closeBtn.addEventListener(MouseEvent.CLICK, this.closeHandler);
            return;
        }// end function

        protected function closeHandler(event:MouseEvent) : void
        {
            this.visible = false;
            return;
        }// end function

        public function open() : void
        {
            this.render();
            this.visible = true;
            return;
        }// end function

        public function set model(param1:String) : void
        {
            this._model = param1;
            if (this.visible)
            {
                this.render();
            }
            return;
        }// end function

        private function render() : void
        {
            if (this.sp == null)
            {
                this.sp = new Sprite();
                this.addChild(this.sp);
                this.sp.mouseEnabled = false;
                this.sp.mouseChildren = false;
            }
            if (this.roleshow == null)
            {
                this.roleshow = new RoleShow(this._model, 4, null, null, null);
                this.roleshow.x = 173 + 30;
                this.roleshow.y = 340;
                this.sp.addChild(this.roleshow);
                this.roleshow.mouseEnabled = false;
                this.roleshow.mouseChildren = false;
            }
            else
            {
                this.roleshow.updateModel(this._model);
            }
            this.visible = true;
            return;
        }// end function

        public function clear() : void
        {
            if (this.roleshow)
            {
                if (this.roleshow.parent)
                {
                    this.roleshow.parent.removeChild(this.roleshow);
                }
                this.roleshow.destroy();
                this.roleshow = null;
            }
            this.visible = false;
            return;
        }// end function

    }
}
